From: Stéphane Démurget Date: Thu, 8 Nov 2012 14:38:57 +0000 (+0100) Subject: messageTray: Close the notification on Escape X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~5459 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=f30dcad8a711069c58f35863ac5c0046ea48d7b6;p=gnome-shell.git messageTray: Close the notification on Escape Now that the notifications can be focused with the keyboard, it's important we can close the active one also this way. https://bugzilla.gnome.org/show_bug.cgi?id=652082 --- diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js index 2f714b0b4..6a2e43005 100644 --- a/js/ui/messageTray.js +++ b/js/ui/messageTray.js @@ -1394,6 +1394,8 @@ const MessageTray = new Lang.Class({ y_expand: true, x_expand: true, layout_manager: new Clutter.BinLayout() }); + this._notificationWidget.connect('key-release-event', Lang.bind(this, this._onNotificationKeyRelease)); + this.actor.add_actor(this._notificationWidget); this._notificationBin = new St.Bin({ y_expand: true }); @@ -1443,7 +1445,7 @@ const MessageTray = new Lang.Class({ this._closeButton = makeCloseButton(); this._closeButton.hide(); - this._closeButton.connect('clicked', Lang.bind(this, this._onCloseClicked)); + this._closeButton.connect('clicked', Lang.bind(this, this._closeNotification)); this._notificationWidget.add_actor(this._closeButton); this._idleMonitorBecameActiveId = 0; @@ -1598,7 +1600,19 @@ const MessageTray = new Lang.Class({ return false; }, - _onCloseClicked: function() { + _onNotificationKeyRelease: function(actor, event) { + let ignoredModifiers = global.display.get_ignored_modifier_mask(); + let modifierState = event.get_state() & ~ignoredModifiers; + + if (event.get_key_symbol() == Clutter.KEY_Escape && modifierState == 0) { + this._closeNotification(); + return true; + } + + return false; + }, + + _closeNotification: function() { if (this._notificationState == State.SHOWN) { this._closeButton.hide(); this._notificationClosed = true;